package com.hangxin.system.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class GlobalUtil {
      
       public static String getProperty(String key){
           loadProperties();
           return props.getProperty(key);
       }
      
       public static void setProperty(String key,String value){
           loadProperties();
           props.setProperty(key,value);
       }
       
       private static Properties props = null;
       
       private static synchronized void loadProperties(){
           
           if (props==null){
               props = new Properties();
               InputStream is = null;	
               try{
                   is = GlobalUtil.class.getClassLoader().getResourceAsStream("config.properties");
                   props.load(is);
               }catch(IOException e){
                   System.out.println("加载配置文件出错！");
               }finally{
                   if (is != null){
                       try{
                           is.close();
                       }catch(IOException e){
                           e.printStackTrace();
                       }
                   }
               }
           }
       }
}
